<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.kingbi.util.ConstantFiles.UserConstant"%>
<%@page import="java.util.List"%>
<%@page import="com.kingbi.system.function.jsfBean.FunctionDataBean"%>
<%@page import="com.kingbi.util.ConstantFiles.SysMagContant"%>
<%@page import="com.kingbi.util.StringUtil"%>
<jsp:directive.page import="com.kingbi.system.login.model.LoginModel" />
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
	<f:view>
		<h:form id="leftMenuForm">
			<h:inputHidden id="A" value="#{loginBean.userID}"></h:inputHidden>
			<head>
				<title></title>
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
				<link type="text/css" rel="stylesheet" href="<%=path%>/css/left.css" />
				<script type="text/javascript" src="<%=path%>/js/jquery-1.3.1.min.js" charset="utf-8"></script>
				<script type="text/javascript" src="<%=path%>/js/function.js" charset="utf-8"></script>
				
				<%
					LoginModel model = (LoginModel) session.getAttribute(UserConstant.USER_MAP_MODEL_KEY_NAME);
					String userName = model.getUserName();
					List funList = (List) session.getAttribute(UserConstant.USER_MAP_LEFT_FUN_LIST_KEY_NAME);
					String fristMainPage = (String) session.getAttribute(UserConstant.USER_MAP_MAIN_FRIST_PAGE_KEY_NAME);
					String from = request.getParameter("from") == null ? "" : request.getParameter("from");
					if (from.equals("welcome")) {// 欢迎页面
						fristMainPage = path + "/faces/toWelcome.jsf";
					} else {
						fristMainPage = path + fristMainPage;
					}
				%>
				<script type="text/javascript">
					$(function(){
						<%
							if (from.equals("welcome")) {// 欢迎页面
								
							} else {
						%>
								select('<%=fristMainPage%>');
						<%		
							}
						%>
					});
				</script>
			</head>

			<body>
				<div class="L_list">
				  <p class="f12"><strong>用户信息</strong><br />
				  <script type="text/javascript">
                            function PageDate()
                            {
                                var currentDate = new Date()
                                with (currentDate)
                                {
                                    day=getDay()
                                    month=getMonth()+1
                                    this.document.write(getFullYear()+'年'+month+'月'+getDate()+'日')
                                }
                                if (day==1){document.write(' 星期一')}
                                if (day==2){document.write(' 星期二')}
                                if (day==3){document.write(' 星期三')}
                                if (day==4){document.write(' 星期四')}
                                if (day==5){document.write(' 星期五')}
                                if (day==6){document.write(' 星期六')}
                                if (day==0){document.write(' 星期日')}
                                document.write('<br>')
                            }
                            PageDate();
                    </script>
				    用户名：<span class="blue"><%=StringUtil.substring(userName, 18, true)%></span><br />
				    您好！</p>
				  <ul id="ulList">
						<%
									if (funList != null && funList.size() > 0) {
										for (int i = 0; i < funList.size(); i++) {
											FunctionDataBean funModel = new FunctionDataBean();
											funModel = (FunctionDataBean) funList.get(i);
											//没有子菜单的二级菜单
											if (funModel.getHasChild() != null && funModel.getHasChild().equals("0") && funModel.getFuncLevel() != null
											&& funModel.getFuncLevel().equals(SysMagContant.FUNCTION_LEVEL_TWO)) {
							%>
						<li class="cur">
							<a href="#" class="atitle"><%=funModel.getFunName()%></a>
							<div style="display: none;" class="Tlist">
								<a
									href="<%=path%><%=funModel.getPageUrl()%>&funRight=<%=funModel.getFunRight()%>"
									target="rightFrame"><%=funModel.getFunName()%></a>
							</div>
						</li>

						<%
										}//有子菜单的二级菜单
										else if (funModel.getHasChild() != null && funModel.getHasChild().equals("1") && funModel.getFuncLevel() != null
											&& funModel.getFuncLevel().equals(SysMagContant.FUNCTION_LEVEL_TWO)) {
									//  System.out.println("*****************有子菜单的二级菜单");
							%>

						<li>
							<a href="#" class="atitle"><%=funModel.getFunName()%></a>
							<div style="display: none;" class="Tlist">
								<%
									}
													//三级菜单
													else if (funModel.getFuncLevel() != null
															&& funModel.getFuncLevel().equals(
																	SysMagContant.FUNCTION_LEVEL_THREE)) {
														//  System.out.println("*****************三级菜单");
								%>

								<a
									href="<%=path%><%=funModel.getPageUrl()%>&funRight=<%=funModel.getFunRight()%>"
									target="rightFrame"><%=funModel.getFunName()%></a>
								<%
									}
													//本二级菜单下的三级菜单结束
													else if (funModel.getThisTwoMenuEnd() != null
															&& funModel.getThisTwoMenuEnd().equals(
																	"end")) {
														//System.out.println("*****************本二级菜单下的三级菜单结束");
								%>
							</div>
						</li>

						<%
							}
										}
									}
						%>
					</ul>
				</div>
				 
				<script type="text/javascript">
				var ulList=document.getElementById("ulList").getElementsByTagName("li");
				var alinks=document.getElementById("ulList").getElementsByTagName("a");
				var divlinks="";
				for(i=0;i<ulList.length;i++){
					ulList[i].getElementsByTagName("a")[0].num=i;
					//--添加第一个菜单展示状态
					if(i == 0){
						ulList[i].getElementsByTagName("div")[0].style.display="block";
						ulList[i].className="cur";
					}
					
					ulList[i].getElementsByTagName("a")[0].onclick=function(){
						for(i=0;i<ulList.length;i++){
							ulList[i].className="";
							try{ulList[i].getElementsByTagName("div")[0].style.display="none";}
							catch(e){}
						}
						ulList[this.num].className="cur";
						try{ulList[this.num].getElementsByTagName("div")[0].style.display="block";}
						catch(e){}
						return false;
					}
					try{divlinks=ulList[i].getElementsByTagName("div")[0].getElementsByTagName("a");
					for(j=0;j<divlinks.length;j++){
						divlinks[j].onclick=function(){
							for(i=0;i<alinks.length;i++){
								alinks[i].className="";
							}
							this.className="acur";
							for(i=0;i<ulList.length;i++){
								ulList[i].getElementsByTagName("a")[0].className="atitle";
							}
						}
					}}
					catch(e){}
				}
				</script>
		
			</body>
		</h:form>
	</f:view>
</html>
<script type="text/javascript">
	function select(pageUrl) 
	{
	    window.parent.document.all.rightFrame.contentWindow.location=pageUrl;
	}
</script>
